package com.ql.controller;


import com.ql.domain.CementMixing;
import com.ql.domain.request.ConditionQuery;
import com.ql.domain.request.PermissionQuery;
import com.ql.domain.response.JsonResult;
import com.ql.domain.TestBean;
import com.ql.service.CementMixingService;

import com.ql.service.SelectTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/cement")
public class CementMixingController {
    @Autowired
    CementMixingService cementMixingService;

    @RequestMapping("/findAll.do")
    @ResponseBody
    public JsonResult findAll(ConditionQuery conditionQuery, @RequestParam(name = "page", required = true, defaultValue = "1") Integer page, @RequestParam(name = "limit", required = true, defaultValue = "10") Integer limit) throws ParseException {
        return cementMixingService.findByCriteria(conditionQuery, page, limit);
    }

    @RequestMapping("/selectBox.do")
    @ResponseBody
    public Map selectBox() throws Exception {
        HashMap<String, Object> map = new HashMap<>();
        List<String> pileNumList = cementMixingService.findPileNum();
        map.put("list", pileNumList);
        return map;
    }


    @RequestMapping("/test.do")
    @ResponseBody
    public JsonResult test() {
        ArrayList<TestBean> list = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            list.add(new TestBean("小霸王"));
        }
        return JsonResult.success(list);
    }

    @RequestMapping("/operationAll.do")
    @ResponseBody
    public  JsonResult operationAll(PermissionQuery permissionQuery, CementMixing cementMixing, @RequestParam(name = "page", required = true, defaultValue = "1") Integer page, @RequestParam(name = "limit", required = true, defaultValue = "10") Integer limit){
       return cementMixingService.findOperationAll(permissionQuery,cementMixing,page,limit);
    }
}
